package com.ee.chat.admin.controller.channelmanage;

import com.ee.chat.admin.service.IChannelConfigService;
import com.ee.chat.common.bean.Result;
import com.ee.chat.common.entity.ChannelConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author Shane
 * @Date 2020/4/17 14:54
 */
@RestController
@RequestMapping("channelConfig")
public class ChannelConfigController {
    private Logger log= LoggerFactory.getLogger(ChannelConfigController.class);

    @Resource
    IChannelConfigService channelConfigService;

    /**
     * 落地页列表
     * @Author Shane
     * @Date 2020/4/17 15:32
     * @param 
     * @return 
     */
    @RequestMapping("list")
    public Result list(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit, Integer status){
        try {
            return channelConfigService.list(request, page, limit, status);
        } catch (Exception e){
            log.error("【获取落地页落地页列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 编辑落地页
     * @Author Shane
     * @Date 2019/11/23 16:29
     * @param
     * @return
     **/
    @RequestMapping("toEdit")
    public Result toEdit(HttpServletRequest request, Integer id){
        try {
            return channelConfigService.toEdit(request, id);
        } catch (Exception e){
            log.error("【编辑落地页错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 保存落地页
     * @Author Shane
     * @Date 2019/11/23 16:52
     * @param
     * @return
     **/
    @RequestMapping("save")
    public Result add(HttpServletRequest request, ChannelConfig channelConfig){
        try {
            return channelConfigService.save(request, channelConfig);
        } catch (Exception e){
            log.error("【保存落地页错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 更新落地页状态
     * @Author Shane
     * @Date 2019/9/1118:12
     * @param id    用户id
     * @return
     **/
    @RequestMapping("updateStatus")
    public Result updateStatus(HttpServletRequest request, @RequestParam Integer id, @RequestParam Integer status){
        try {
            return channelConfigService.updateStatus(request, id, status);
        } catch (Exception e){
            log.error("【更新落地页状态错误】", e);
        }
        return Result.returnFailure();
    }
}
